home *** CD-ROM | disk | FTP | other *** search
-
- //--------------------------------------------------------------------------------------------
- // global variables
- //--------------------------------------------------------------------------------------------
-
- var m_currentScreenName = "no-USSetting";
-
-
- //--------------------------------------------------------------------------------------------
- // DoOnClick
- //
- // NB: This function usually looks at the ID of the object that generated
- // the event to determine what action to perform - it's kind of a poor man's
- // state machine. In order to add support for keyboard navigation (next page
- // and cancel), I have added a parameter to the method call that let's the
- // caller specify what ID to use as the event source. If no parameter is passed
- // the actual event.srcElement.id property is still used, so this does not
- // break the existing code...
- //
- // jc 6/00
- //--------------------------------------------------------------------------------------------
-
- function DoOnClick(fake_id)
- {
- var src = window.event.srcElement;
- var Dict = window.dialogArguments; // incoming dictionary
- var mainWindow = Dict.Item("kWindow");
- var source_id = (fake_id == null) ? src.id : fake_id;
-
- //alert("DoOnClick: " + source_id);
-
- switch (source_id)
- {
-
- ////////////////////////////////////////////////////////
- // we- Welcome screen for user who is online.
- // wo- Welcome screen for user who needs to go online.
- ////////////////////////////////////////////////////////
- case "we-next":
- mainWindow.external.CheckForServerAccount();
- break;
- case "wo-next":
- {
- if(mainWindow.external.InternetConnectionIsOpen())
- {
- mainWindow.external.CheckForServerAccount();
- }
- else
- {
- mainWindow.external.GoOnline();
- var Str = mainWindow.external.GetResourceString(6234);
- mainWindow.document.all("elemMessage").innerHTML = Str;
-
- SetVisibleDIV(""); // Prevent Closing() from killing the app.
- window.close();
- }
- break;
- }
- case "we-SelLaterBtn":
- case "wo-SelLaterBtn":
- {
- window.close();
- break;
- }
-
-
- ////////////////////////////////////////////////////////
- // sa- Checking for Server Account.
- ////////////////////////////////////////////////////////
- case "sa-Cancel":
- window.close();
- break;
-
-
- ////////////////////////////////////////////////////////
- // rot- Screen displayed while we are synchronizing.
- ////////////////////////////////////////////////////////
-
- case "rot-Cancel":
- window.close();
- break;
-
-
- ////////////////////////////////////////////////////////
- // cp- "Setup is now complete. ...
- ////////////////////////////////////////////////////////
- case "cp-Start":
- window.close();
- mainWindow.external.NavigateToCalendar();
- break;
-
- case "cp-Cancel":
- window.close();
- break;
-
-
- ////////////////////////////////////////////////////////
- // nocr- "Where do you live?
- ////////////////////////////////////////////////////////
- case "nocr-Cancel":
- window.close();
- break;
- case "nocr-Back":
- // SetVisibleDIV ("welcomS");
- break;
- case "nocr-Next":
- if (window.document.all("radUS").checked == true)
- {
- SetVisibleDIV ("no-USSetting");
- }
- else
- {
- SetVisibleDIV ("no-NOUSSetting");
- }
- break;
-
-
- ////////////////////////////////////////////////////////
- // nous- Enter information for US user:
- ////////////////////////////////////////////////////////
- case "nous-Cancel":
- window.close();
- break;
- case "nous-Back":
- // SetVisibleDIV ( "no-SetReg");
- break;
- case "nous-Next":
- {
- var retValue = GetUSInfoFromUI (Dict);
- if (retValue)
- {
- SetVisibleDIV ("NewAcct");
- GetCallerWindow().external.CreateNewUserAccount(Dict);
- }
- }
- break;
-
-
- ////////////////////////////////////////////////////////
- // nonu- Enter information for non-US user:
- ////////////////////////////////////////////////////////
- case "nonu-Cancel":
- window.close();
- break;
- case "nonu-Back":
- // SetVisibleDIV ("no-SetReg");
- break;
- case "nonu-Next":
- {
- var retValue = GetRegionInfoFromUI (Dict);
- if (retValue)
- {
- SetVisibleDIV ("NewAcct");
- GetCallerWindow().external.CreateNewUserAccount(Dict);
- }
- }
- break;
-
-
- ////////////////////////////////////////////////////////
- // na- Creating new account:
- ////////////////////////////////////////////////////////
- case "na-Cancel":
- window.close();
- break;
-
- }
- }
-
- //--------------------------------------------------------------------------------------------
- // DoOnKeyPress
- //--------------------------------------------------------------------------------------------
- function DoOnKeyPress ()
- {
- var keyF8 = 119;
- if (68 == event.keyCode && event.ctrlKey && event.shiftKey) // Ctrl-Shift-D
- {
- StartAccessibleVersionOfCalendar();
- return;
- }
-
- var keyEnter = 13;
- var keyEsc = 27;
- var cancel_id = "";
- var ok_id = "";
-
- if (event.keyCode != keyEsc && event.keyCode != keyEnter)
- return;
-
- // This icky switch is used because as the visible DIVs change
- // in the setup wizard, so do the IDs of the buttons. This switch
- // keys off the visible DIV name to select a next or cancel button to
- // 'press' when the Enter or Escape key is hit.
- //
- // screen cancel next
- // "WelcomS" "we-SelLaterBtn" "we-next"
- // "WelcomSO" "wo-SelLaterBtn" "wo-next"
- // "ServAcct" "sa-Cancel"
- // "ro-two" "rot-Cancel"
- // "su-complete" "cp-Start" "cp-Cancel"
- // "no-SetReg" "nocr-Cancel" "nocr-Next"
- // "no-USSetting" "nous-Cancel" "nous-Next"
- // "no-NOUSSetting" "nonu-Cancel" "nonu-Next"
- // "NewAcct" "na-Cancel"
- //
- // jc 6/00
-
- switch(m_currentScreenName)
- {
- /* case "WelcomS":
- cancel_id = "we-SelLaterBtn";
- ok_id = "we-next";
- break; */
-
- case "WelcomSO":
- cancel_id = "wo-SelLaterBtn";
- ok_id = "wo-next";
- break;
-
- case "ServAcct":
- cancel_id = "sa-Cancel";
- break;
-
- case "ro-two":
- cancel_id = "rot-Cancel";
- break;
-
- case "su-complete":
- cancel_id = "cp-Cancel";
- ok_id = "cp-Start";
- break;
-
- case "no-SetReg":
- cancel_id = "nocr-Cancel";
- ok_id = "nocr-Next";
- break;
-
- case "no-USSetting":
- cancel_id = "nous-Cancel";
- ok_id = "nous-Next";
- break;
-
- case "no-NOUSSetting":
- cancel_id = "nonu-Cancel";
- ok_id = "nonu-Next";
-
- case "NewAcct":
- cancel_id = "na-Cancel";
- }
-
- if (keyEnter == event.keyCode && ok_id != "")
- {
- DoOnClick(ok_id);
- }
- else if (keyEsc == event.keyCode && cancel_id != "")
- {
- DoOnClick(cancel_id);
- }
- }
- //--------------------------------------------------------------------------------------------
- // GetUSInfoFromUI
- //--------------------------------------------------------------------------------------------
- function GetUSInfoFromUI (DictValues)
- {
- /* DictValues.Item("kZipCode") = window.document.all("stZipCode").value;
-
- if (DictValues.Item("kZipCode").length < 5)
- {
- alert ("Problem with Zip Code Entry-Please make sure you enter \nvalid 5-digit zip code (numbers only). Thank you.");
- return false;
- } */
-
- DictValues.Item("kTimeZone") = window.document.all("stTimeZoneUS").value;
- //DictValues.Item("kState") = window.document.all("stWState").value;
- //DictValues.Item("kState") = ReplaceSpaceWithPlus(window.document.all("stWState").value);
-
- /* if (window.document.all("stWState").value == "Select a state")
- {
- alert ("Error: Please select a state");
- return false;
- }
- */
- // DictValues.Item("kCity") = ReplaceSpaceWithPlus(window.document.all("stWCity").value);
- // DictValues.Item("kCity") = window.document.all("stWCity").value;
- /* if (DictValues.Item("kCity") == "")
- {
- alert ("Error: Please select a city");
- return false;
- }
- */
- DictValues.Item("kState") = "";
- DictValues.Item("kCity") = "";
- return true;
-
- }
- //--------------------------------------------------------------------------------------------
- // GetRegionInfoFromUI
- //--------------------------------------------------------------------------------------------
- function GetRegionInfoFromUI (DictValues)
- {
- DictValues.Item("kTimeZone") = window.document.all("stTimeZoneNoUS").value;
- if (window.document.all("stWRegion").value == "Select a region" )
- {
- alert ("Error: Please select a region");
- return false;
- }
- //DictValues.Item("kState") = ReplaceSpaceWithPlus (window.document.all("stWCountry").value);
- DictValues.Item("kState") = window.document.all("stWCountry").value;
- if (DictValues.Item("kState") == "")
- {
- alert ("Error: Please select a country");
- return false;
- }
-
- //DictValues.Item("kCity") = ReplaceSpaceWithPlus(window.document.all("stOtherCity").value);
- DictValues.Item("kCity") = window.document.all("stOtherCity").value;
- if (DictValues.Item("kCity") == "")
- {
- alert ("Error: Please select a city");
- return false;
- }
- return true;
- }
- //--------------------------------------------------------------------------------------------
- // ReplaceSpaceWithPlus this function replace the space in string with a +
- //--------------------------------------------------------------------------------------------
- function ReplaceSpaceWithPlus (inStr)
- {
-
- re = / /g;
- outStr = inStr.replace(re, "+");
- return(outStr);
-
- }
- //--------------------------------------------------------------------------------------------
- // GetCallerWindow
- //--------------------------------------------------------------------------------------------
- function GetCallerWindow()
- {
- if(dialogArguments.item("kWindow"))
- return dialogArguments.item("kWindow");
- else
- throw (new Error (0, "Error:The opener window is not passed properly"));
- }
- //--------------------------------------------------------------------------------------------
- // ReplacePlusWithSpace this function replace the space in string with a +
- //--------------------------------------------------------------------------------------------
- function ReplacePlusWithSpace (inStr)
- {
- re = /[+]/g;
- outStr = inStr.replace(re, " ");
- return(outStr);
-
- }
- //--------------------------------------------------------------------------------------------
- // SetVisibleDIV
- //--------------------------------------------------------------------------------------------
- function SetVisibleDIV (ShowW)
- {
- // Is try-catch block expensive? Anyway, seems overkill here.
- // try
- // {
- var oldScreen = window.document.all(m_currentScreenName);
- if (null != oldScreen)
- {
- oldScreen.style.visibility = "hidden";
- }
- if("" != ShowW)
- window.document.all(ShowW).style.visibility = "visible";
- m_currentScreenName = ShowW;
- // }
- // catch(e)
- // {
- // alert("Error: Could not navigate to the specified screen '" + ShowW + "'");
- // }
- }
-
- //--------------------------------------------------------------------------------------------
- // Closing
- //--------------------------------------------------------------------------------------------
- function Closing()
- {
- var Dict = window.dialogArguments; // incoming dictionary
- var mainWindow = Dict.Item("kWindow");
-
- switch( m_currentScreenName ) {
- // case "WelcomS":
- case "WelcomSO":
- {
- mainWindow.external.Quit();
- break;
- }
- case "":
- // Closing dialog window so we can sign on.
- break;
- case "su-complete":
- var Str = mainWindow.external.GetResourceString(6235);
- mainWindow.document.all("elemMessage").innerHTML = Str;
-
- break;
- default:
- mainWindow.external.CancelSetup();
- var Str = mainWindow.external.GetResourceString(6236);
- mainWindow.document.all("elemMessage").innerHTML = Str;
-
- break;
- }
-
- }
-
- //--------------------------------------------------------------------------------------------
- // SetupInitialScreen
- //--------------------------------------------------------------------------------------------
- function SetupInitialScreen()
- {
- var Dict = window.dialogArguments;
- var mainWindow = Dict.Item("kWindow");
- mainWindow.external.SetDialogTitle("AOL Calendar Setup");
- var nextPanel = Dict.Item("kNextPanel");
- SetVisibleDIV( nextPanel );
- }
-
- //--------------------------------------------------------------------------------------------
- // DoAfterGoOnline
- //--------------------------------------------------------------------------------------------
- function DoAfterGoOnline( bServerAccountExists )
- {
- if( bServerAccountExists )
- {
- // SetVisibleDIV( "ro-One");
- SetVisibleDIV( "ro-two");
- }
- else
- {
- SetVisibleDIV( "no-USSetting" ); //( "no-SetReg");
- }
- }
-
- //--------------------------------------------------------------------------------------------
- // ShowServAccount
- //--------------------------------------------------------------------------------------------
- function ShowServAccount()
- {
- var Dict = window.dialogArguments;
- var mainWindow = Dict.Item("kWindow");
- SetVisibleDIV ("ServAcct");
- }
-
- //--------------------------------------------------------------------------------------------
- // SetupComplete
- //--------------------------------------------------------------------------------------------
- function SetupComplete()
- {
- SetVisibleDIV ("su-complete");
- }
-
- //--------------------------------------------------------------------------------------------
- // SetupComplete
- //--------------------------------------------------------------------------------------------
- function SetupFailed()
- {
- var Dict = window.dialogArguments; // incoming dictionary
- var mainWindow = Dict.Item("kWindow");
- var Str = mainWindow.external.GetResourceString(6237);
- mainWindow.document.all("elemMessage").innerHTML = Str;
-
- SetVisibleDIV(""); // Prevent Closing() from overwriting this.
- window.close();
- }
-